#include<unistd.h>
#include<iostream>
#include<cstring>
#include<sys/wait.h>
#include<stdio.h>
using namespace std;
int main()
{
    int fd[2]={0};
    pipe(fd);
    pid_t pid=fork();
    if(pid==0)
    {
        //child
        close(fd[0]);//关闭读端
        char msg[]="a";
        int count=0;
        while(1)
        {
            write(fd[1],msg,strlen(msg));
            count++;
            cout<<count<<endl;
        }
        exit(0);
    }
    close(fd[1]);
    waitpid(pid,NULL,0);
    return 0;
}